<?php
require_once 'CMS/Util.php';
require_once 'CMS/Mvc/BaseController.php';
require_once 'CMS/Mvc/BaseUserController.php';
require_once 'CMS/UserCommon.php';
require_once 'CMS/User.php';

//Người tạo : Nguyễn Nghĩa Hưng - Team 3
//Module 	: Edit question module
//Chức năng	: Hiển thị form edit question

class QuestionAnswer_DeleteController extends BaseUserController {

	public function init(){
		parent::init();
		$this->_helper->layout->disableLayout();
	}
	
	
	public  function indexAction() {
		$path = APPLICATION_PATH."/widgets/questionanswer/";
		$xmlconfig = new SimpleXMLElement($path."config.xml",null,true);//Read config.xml
		$user = new User();
			$user->init();
			$user->check_login();
			$hasmodify = $user->modifiy_content($xmlconfig->name);
	if($hasmodify=="true")
	{
		if(count($_GET) && isset($_GET["id"]) && is_numeric($_GET["id"]))
		{
			$thing_id = $_GET["id"];
			$tbqa = new QuestionAnswer_Model_Thing();
			//$category = $tbqa->getThingById($thing_id);
			$result = $tbqa->deletething($thing_id);
			if($result==1)
				{$response=1;}//$category[0]['category_id'];
			else
				if($result==-1)
					$response=-1;
		}
		else
			$response=-2;
		$this->_helper->json($response);
	}
	else {
		$response= -3;
		$this->_helper->json($response);
	}
	}	
}